package com.aios.action.timer;

import java.util.ArrayList;
import java.util.List;

import com.aios.entity.DaySchedule;
import com.aios.entity.Switch;

public class TimerEditAction extends AbstractTimerAction {

	private List<Switch> switchList = new ArrayList<Switch>();
	private List<DaySchedule> dayScheduleList;
	private String[] checkedItems;
	
	public List<String> getSettingList() {
		return settingList;
	}

	public void setSettingList(List<String> settingList) {
		this.settingList = settingList;
	}

	public List<DaySchedule> getDayScheduleList() {
		return dayScheduleList;
	}

	public void setDayScheduleList(List<DaySchedule> dayScheduleList) {
		this.dayScheduleList = dayScheduleList;
	}

	public List<Switch> getSwitchList() {
		return switchList;
	}

	public void setSwitchList(List<Switch> switchList) {
		this.switchList = switchList;
	}

	private static final long serialVersionUID = 1L;

	public String execute() {
		
		setMode(Mode.EDIT);
		
		if (actionMessage != null && actionMessage != "") {
			addActionMessage(actionMessage);
		}
		
		try {
			timerSetting = timerService.findByIdWithSchedule(id);
			setDayListValues(timerSetting);
			populateWeekList();
			switchList = switchService.findBySwitchPanel(timerSetting.getTimer().getSwitchId());
			populateSelectedDays();
			populateHourList();
			populateMinList();
			setSettingList();
			
			calTime(timerSetting.getTimer().getTrigerTime());

		} catch (Exception e) {
			e.printStackTrace();
			addActionError(getText("error.user.notfound"));
		}
		return SUCCESS;

	}
	
	public String[] getCheckedItems() {
		return checkedItems;
	}

	public void setCheckedItems(String[] checkedItems) {
		this.checkedItems = checkedItems;
	}

}
